using log4net;
using log4net.Config;
using log4net.Repository.Hierarchy;
using System.Reflection;

namespace Koala.Pro.CodeGenerator.UI
{
    internal static class Program
    {
        private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        public static GlobalControl global = new GlobalControl();

        [STAThread]
        static void Main()
        {
            var repository = LogManager.GetRepository(Assembly.GetEntryAssembly());
            XmlConfigurator.Configure(repository, new FileInfo("log4net.config"));

            log.Info("Application started.");

            ApplicationConfiguration.Initialize();

            global.MainView = new FrmMain();
            Application.Run(global.MainView);

            Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
        }

        private static void Application_ApplicationExit(object? sender, EventArgs e)
        {
            log.Info("Application exit.");
            LogManager.Shutdown();
        }
    }
}